class EmailerController < ApplicationController

  before_filter :check_admin 

  def send_email

    if request.post?
          from = params[:from]
          subject = params[:subject]
          message = params[:message]
          name = params[:name]

          if !from.blank? and !subject.blank? and !message.blank? and !name.blank?
            Emailer.deliver_contact(from, subject, message)
            return if request.xhr?
            render :text => 'O email foi enviado com sucesso'
          else
            @form_error = 'Não foi enviado o email'
          end
        end
          
    #        email = @params["email"]
    #	  recipient = email["recipient"]
    #	  subject = email["subject"]
    #	  message = email["message"]
    #      Emailer.deliver_contact(recipient, subject, message)
    #      return if request.xhr?
    #      render :text => 'Message sent successfully'
   end


end
